<!DOCTYPE HTML>
<html>
<head> 
	<link rel="stylesheet" href="/static/table_stylesheet.css">
	<link rel="stylesheet" href="/static/generic_stylesheet.css">
	<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'></script>
	<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
        <script type="text/javascript" src="/static/table_script.js"></script>
	<script type="text/javascript" src="/static/table_search.js"></script>
	<title>Marketplace</title>
 </head>
 <body>
 <div class="sidebar">
 	 {% if user %}
	<div class="button">
	<a href='/profile'><img src="/static/profile.png"/></a>
	</div>
	<br />
 	<div class="button">
	<a href='/logout'><img src="/static/logout.png"/></a>
	</div>
	<br />
	{% endif %}
 	{% if is_admin %}
 	<div class="button">
	<a href='/admin'><img src="/static/adminpanel.png"/></a>
	</div>
	{% endif %}
 </div>
 
 <div class="main">
 	{% if user %}
 	<h1> Hi {{usernick}}! </h1>

 	{% else %}
 	<h1> Hi guest! </h1>
 	{% endif %}
 	
 	<div id = "page-wrap">
	<input type="text" id="search" placeholder="Search" />
 	<table border="1" id="browse_table" bordercolor="#FFCC00" style="background-color:#FFFFCC" width="85%" cellpadding="3" cellspacing="0"><tr id="browse_header"> 
                                <td><b>Title</b></td>
                                <td><b>Seller</b></td>
                                <td><b>Price</b></td>
                                <td><b>Creation Date</b></td>
                                <!--<td><b>Details</b></td>-->
                                </tr>

    {% for i in data %}
		{% if i.Activated==True %}
		
		<tr><td> <form name="item_detail" action="/item_detail" method="get">
		<input type="text" value= "{{i.Key_Date}}" name="key_name" style="display:none">
		<button type="submit" class="blue-button">{{i.Title}} </button> </form>  </td>
		<td> {{i.Seller.nickname()}}</td>
		<td> {{i.Price}} </td>
		<td> {{i.Creation_Date}} </td>
		{% endif %}
    <!--
    <td><form name="item_detail" action="/item_detail" method="get">
    <input type="text" value= "{{i.Key_Date}}" name="key_name" style="display:none">
    <button type="submit">Details</button>
</form></td>--></tr> 
	{% endfor %}
</table>
</div>

<br>

<form method="get" action="/post_item">
	{% if user %}
                                <button type="submit"  class="red-button">Post Item</button>
                            </form>
	{% endif %}
</div>
</body>
</html>
